package p270jp.pxv.android.advertisement.presentation.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import com.socdm.p087d.adgeneration.ADG;
import com.socdm.p087d.adgeneration.ADGConsts;
import com.socdm.p087d.adgeneration.ADGListener;
import p062c4.ViewBindings;
import p064c6.Preconditions;
import p072ce.ViewRectangleAdgAutoRotationViewBinding;
import p189gn.AbstractC3435a;
import p216hn.Lambda;
import p216hn.Reflection;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.model.GoogleNg;
import p284ke.AdUtils;
import p325m0.MutabilityOwnership;
import p376no.Koin;
import p404oo.AbstractC5475a;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;

/* compiled from: RectangleADGAutoRotationView.kt */
/* renamed from: jp.pxv.android.advertisement.presentation.view.RectangleADGAutoRotationView */
/* loaded from: classes2.dex */
public final class RectangleADGAutoRotationView extends FrameLayout implements AbstractC5475a {

    /* renamed from: a */
    public final ViewRectangleAdgAutoRotationViewBinding f18845a;

    /* renamed from: b */
    public ADG f18846b;

    /* renamed from: c */
    public final AbstractC6949c f18847c = Preconditions.m9802P(1, new C4179b(this, null, null));

    /* compiled from: RectangleADGAutoRotationView.kt */
    /* renamed from: jp.pxv.android.advertisement.presentation.view.RectangleADGAutoRotationView$a */
    /* loaded from: classes2.dex */
    public static final class C4177a extends ADGListener {

        /* compiled from: RectangleADGAutoRotationView.kt */
        /* renamed from: jp.pxv.android.advertisement.presentation.view.RectangleADGAutoRotationView$a$a */
        /* loaded from: classes2.dex */
        public /* synthetic */ class C4178a {

            /* renamed from: a */
            public static final /* synthetic */ int[] f18849a;

            static {
                int[] iArr = new int[ADGConsts.ADGErrorCode.values().length];
                iArr[ADGConsts.ADGErrorCode.EXCEED_LIMIT.ordinal()] = 1;
                iArr[ADGConsts.ADGErrorCode.NEED_CONNECTION.ordinal()] = 2;
                iArr[ADGConsts.ADGErrorCode.NO_AD.ordinal()] = 3;
                f18849a = iArr;
            }
        }

        public C4177a() {
            RectangleADGAutoRotationView.this = r1;
        }

        @Override // com.socdm.p087d.adgeneration.ADGListener
        public void onFailedToReceiveAd(ADGConsts.ADGErrorCode aDGErrorCode) {
            int i = aDGErrorCode == null ? -1 : C4178a.f18849a[aDGErrorCode.ordinal()];
            if (i != 1 && i != 2 && i != 3) {
                ADG adg = RectangleADGAutoRotationView.this.f18846b;
                MutabilityOwnership.m3747j(adg);
                adg.start();
            }
        }

        @Override // com.socdm.p087d.adgeneration.ADGListener
        public void onReceiveAd() {
            RectangleADGAutoRotationView.this.f18845a.f5432r.setVisibility(8);
        }
    }

    /* compiled from: KoinComponent.kt */
    /* renamed from: jp.pxv.android.advertisement.presentation.view.RectangleADGAutoRotationView$b */
    /* loaded from: classes2.dex */
    public static final class C4179b extends Lambda implements AbstractC3435a<AdUtils> {

        /* renamed from: a */
        public final /* synthetic */ AbstractC5475a f18850a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4179b(AbstractC5475a aVar, Qualifier aVar2, AbstractC3435a aVar3) {
            super(0);
            this.f18850a = aVar;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [java.lang.Object, ke.a] */
        @Override // p189gn.AbstractC3435a
        public final AdUtils invoke() {
            return this.f18850a.getKoin().f24118a.m920a().m621a(Reflection.m5499a(AdUtils.class), null, null);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public RectangleADGAutoRotationView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        MutabilityOwnership.m3745m(context, "context");
        MutabilityOwnership.m3745m(attributeSet, "attributeSet");
        ViewDataBinding c = DataBindingUtil.m11370c(LayoutInflater.from(getContext()), R.layout.view_rectangle_adg_auto_rotation_view, this, true);
        MutabilityOwnership.m3746l(c, "inflate(LayoutInflater.f…otation_view, this, true)");
        this.f18845a = (ViewRectangleAdgAutoRotationViewBinding) c;
    }

    private final AdUtils getAdUtils() {
        return (AdUtils) this.f18847c.getValue();
    }

    @Override // p404oo.AbstractC5475a
    public Koin getKoin() {
        return AbstractC5475a.C5476a.m3211a(this);
    }

    public void setGoogleNg(GoogleNg googleNg) {
        MutabilityOwnership.m3745m(googleNg, "googleNg");
    }

    public final void setup(String str) {
        MutabilityOwnership.m3745m(str, "locationId");
        ADG adg = this.f18846b;
        if (adg != null) {
            this.f18845a.f5431q.removeView(adg);
            ADG adg2 = this.f18846b;
            if (adg2 != null) {
                ViewBindings.m9831f(adg2);
            }
        }
        ADG adg3 = new ADG(getContext());
        this.f18846b = adg3;
        adg3.setReloadWithVisibilityChanged(false);
        ADG adg4 = this.f18846b;
        MutabilityOwnership.m3747j(adg4);
        adg4.setAdListener(new C4177a());
        ADG adg5 = this.f18846b;
        MutabilityOwnership.m3747j(adg5);
        adg5.setLocationId(str);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
        layoutParams.gravity = 17;
        ADG adg6 = this.f18846b;
        MutabilityOwnership.m3747j(adg6);
        adg6.setLayoutParams(layoutParams);
        ADG adg7 = this.f18846b;
        MutabilityOwnership.m3747j(adg7);
        adg7.setAdFrameSize(ADG.AdFrameSize.FREE.setSize(300, 250));
        this.f18845a.f5431q.addView(this.f18846b);
    }
}
